<template>
    <div>
        <p>姓名：<input type="text" v-model="name"></p>
        <p>年纪：<input type="text" v-model="age"></p>
        <p>手机：<input type="text" v-model="phone"></p>
        <p>邮箱：<input type="text" v-model="email"></p>
        <p>图片：<input type="file" @change="getfile($event)"></p>
        <p><input type="button" value="添加" @click="apps()"></p>
        <p><img v-if="a==2" src="url" alt="图片"></p>
    </div>
</template>

<script>
import axios from "axios" 
export default {
    name:"qiniuyun",
    data(){
        return{
            a:"1",
            pic_url:"",
            name:"",
            age:"",
            phone:"",
            email:"",
        }
    },
    methods:{
        apps(){
            var data= new FormData()
            data.append("pic",this.file)
            data.append("name",this.name)
            data.append("age",this.age)
            data.append("phone",this.phone)
            data.append("email",this.email)
            axios({
                url:"http://127.0.0.1:8000/qin/qis",
                method:"POST",
                data:data
            }).then(res=>{
                console.log(res)
                this.goods=res.data
                // if(res.data.code==200){
                //     this.a="2"
                //     this.pic_url = res.data.url6
                // }
            })
        },
        getfile(event){
            this.file = event.target.files[0]
        },
    }
}
</script>
